﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Cherry.Agile.Security
{
    /// <summary>
    /// 用户密码票据
    /// </summary>
    [Serializable]
    [DataContract]
    public class AccountTicket:ITicket
    {
        /// <summary>
        /// Ctor
        /// </summary>
        public AccountTicket()
        {
            SecurityZone = (int)Cherry.Agile.Security.SecurityZone.Shared;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        public AccountTicket(User user)
        {
            this.Identity = user.Identity;
            this.Type = user.UserType;
            this.Id = user.ID;
        }

        /// <summary>
        /// 用户ID
        /// </summary>
        [DataMember] 
        public int Id { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        [DataMember] 
        public string Identity { get; set; }

        /// <summary>
        /// 用户类型
        /// </summary>
        [DataMember]
        public int Type { get; set; }

        /// <summary>
        /// 验证方式
        /// </summary>
        [DataMember]
        public int ValidateType { get; set; }

        /// <summary>
        /// 权限验证范围
        /// </summary>
        public int SecurityZone  { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [DataMember]
        public string Password { get; set; }

        /// <summary>
        /// 数据是否加密
        /// </summary>
        [DataMember]
        public bool Encrypted
        {
            get;
            set;
        }
    }
}
